<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增课程</title>
    <script src="js/base.js"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
        }
        h1 {
            font-size: 2em;
            color: #333;
            text-align: center;
            margin-bottom: 20px;
        }
        input[type="text"] {
            width: 30%;
            padding: 10px;
            margin: 10px 0;
            border: 1px solid #ccc;
            border-radius: 5px;
            font-size: 14px;
        }
        button {
            padding: 10px 20px;
            margin: 10px 0;
            background-color: #007BFF;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 14px;
        }
        button:hover {
            background-color: #0056b3;
        }
        .form-container {
            width: 100%;
            max-width: 400px;
            background: #fff;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            text-align: center; /* 添加居中对齐 */
        }
        .button-container {
            display: flex;
            justify-content: center; /* 按钮居中 */
        }
    </style>
</head>
<body>
    <h1>新增课程</h1>
    课程名称：<input type="text" id="name"><br/>
    授课教师：<input type="text" id="tname"><br/>
    教室容量：<input type="text" id="maxLimit"><br/>
    <div class="button-container">
        <button onclick="onAddClick()">确认添加</button></div>
    <script>
        function onAddClick(){
            let url="http://localhost:8080/teacher/addCourse";
            let method="post";
            let json={};
            json.name=document.getElementById("name").value;
            json.tname=document.getElementById("tname").value;
            json.maxLimit=document.getElementById("maxLimit").value;
            $.rest(url,method,json,function (r){
                if (r.code==200){
                    alert("新增成功");
                    window.location.href="teacherIndex.html";
                }else if(r.code==500){
                    alert("教师不存在");
                }else{
                    alert("新增错误");
                }
            });

        }
    </script>
</body>
</html>